using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Deepcode.Flux.Core.Services.FileSystem.Comparers
{
	/// <summary>
	/// Compares two FileInfo objects and returns sort indexes
	/// based on the name in descending order.
	/// </summary>
	public class FileInfoNameDESCComparer : IComparer<FileInfo>
	{
		/// <summary>
		/// Returns 0 if two items are equal, 
		/// -1 if x > y 
		/// 1 if x < y
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <returns></returns>
		public int Compare(FileInfo x, FileInfo y)
		{
			if (x == null && y == null) return 0;
			if (x == null && y != null) return 1;
			if (x != null && y == null) return -1;

			return String.Compare(x.Name, y.Name, true) * -1;
		}
	}
}
